package product

import (
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"vue-admin-server/global"
	"vue-admin-server/model/common/response"
)

type ChipCosReportApi struct{}

func (e *ChipCosReportApi) GetHistory(c *gin.Context) {
	chipIdStr := c.Query("chipId")
	if len(chipIdStr) == 0 {
		response.FailWithMessage("chipId 不能为空", c)
		return
	}

	cosReports, err := cosReportService.GetCosReportHistory(chipIdStr)
	if err != nil {
		global.GVA_LOG.Error("获取失败!", zap.Error(err))
		response.FailWithMessage("获取失败", c)
	} else {
		response.OkWithDetailed(cosReports, "获取成功", c)
	}
}

func (e *ChipCosReportApi) GetCosReportInfo(c *gin.Context) {
	chipIdStr := c.Query("chipId")
	if len(chipIdStr) == 0 {
		response.FailWithMessage("chipId 不能为空", c)
		return
	}

	reportIdStr := c.Query("reportId")
	if len(reportIdStr) == 0 {
		response.FailWithMessage("reportId 不能为空", c)
		return
	}

	cosReports, err := cosReportService.GetCosReportInfo(chipIdStr, reportIdStr)
	if err != nil {
		global.GVA_LOG.Error("获取失败!", zap.Error(err))
		response.FailWithMessage("获取失败", c)
	} else {
		response.OkWithDetailed(cosReports, "获取成功", c)
	}
}
